package cn.codeinn.service1.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.codeinn.common.util.RS;
import cn.codeinn.model.vo.MemberVO;
import cn.codeinn.service1.service.MemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api
@RestController
@RequestMapping(value = "/member")
public class MemberController {

	@Autowired
	private MemberService memberService;

	@ApiOperation(value = "根据ID查询member")
	@GetMapping(value = "/{id}")
	public MemberVO selectMember(@PathVariable Integer id) {
		return memberService.selectMember(id);
	}

	@PostMapping(value = "/clearCache")
	@CacheEvict(value = "memberCache", allEntries = true)
	public RS clearCache() {
		return RS.ok();
	}

	@GetMapping(value = "/async")
	public RS testAysncService() {
		memberService.doTestAsync();
		return RS.ok();
	}

}
